package com.zlq.cn.service.un;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zlq.cn.bootstrap.SignApiBootstrap;
import com.zlq.cn.entity.FanyiUser;
import com.zlq.cn.entity.WnxsPoetry;
import com.zlq.cn.mapper.un.WnxsPoetryMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * <p>
 * 为你写诗 服务实现类
 * </p>
 *
 * @author zhoucl
 * @since 2022-11-21
 */
@Service
public class WnxsPoetryService extends ServiceImpl<WnxsPoetryMapper, WnxsPoetry> {
    @Resource
    private FanyiUserService fanyiUserService;

    @Override
    public boolean save(WnxsPoetry entity) {
        FanyiUser fanyiUser = fanyiUserService.getById(SignApiBootstrap.get().getImei());
        Assert.notNull(fanyiUser, "用户不存在");
        entity.setUserId(fanyiUser.getFanyiUserImei());
        entity.setTime(LocalDateTime.now());
        return super.save(entity);
    }
}
